package com.mc2.docapp.disabilityassessmenttool.ConginitalDef;

import com.mc2.docapp.disabilityassessmenttool.UpperLimb.CustDataType;

import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class Class_Conginital_Deficiency_component extends RealmObject {
    @PrimaryKey
    public int id;
    private CustDataType transverse= new CustDataType() ;
    private CustDataType clubfoot = new CustDataType();
    private double calculation = 0d;


    /*public Class_Conginital_Deficiency_component(int id, CustDataType transverse, CustDataType clubfoot) {
        this.id = id;
        this.transverse = transverse;
        this.clubfoot = clubfoot;
    }*/

    public Class_Conginital_Deficiency_component strip(Class_Conginital_Deficiency_component dt) {
        return new Class_Conginital_Deficiency_component(dt.getId(), dt.getTransverse(), dt.getClubfoot(),dt.getCalculation());

    }

    private void calc (Class_Conginital_Deficiency_component dt) {

        double a = transverse.getActual_left();
        double b = transverse.getActual_right();
        double c = clubfoot.getActual_left();
        double d = clubfoot.getActual_right();

        double step1;
        double step2;
        double step3;

        step1 = calByFormula(a,b);
        step2 = calByFormula(step1,c);
        step3 = calByFormula(step2,d);

        dt.setCalculation(step3);
    }

    private double calByFormula(double a, double b) {
        if(a<b){
            a = a + b;
            b = a - b;
            a = a - b;
        }
        double c = a + ((90-a)*b)/90;
        return  c;
    }
}
